package com.xuan.mail.service.impl;

import com.xuan.mail.config.RabbitMqConfig;
import com.xuan.mail.domin.Email;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EmailProducer {
    @Resource
    private RabbitTemplate rabbitTemplate;

//    @Value("${rabbitmq.email.exchange}")
//    private String exchange;
//
//    @Value("${rabbitmq.email.routing-key}")
//    private String routingKey;

    public void sendEmailToQueue(Email email) {
        rabbitTemplate.convertAndSend(RabbitMqConfig.EMAIL_EXCHANGE,RabbitMqConfig.EMAIL_ROUTING_KEY, email);
    }
}

